<?php

namespace app\common\model;
use think\Db;

class Wares extends Base
{
    /**
     * [getWaresByCondition]
     * @author [南風]
     * @param $map
     * @param $from
     * @param $size
     * @return array
     */
    public function getWaresByCondition($map, $from, $size)
    {
        $order = ['w.create_time' => 'asc'];

        $join = [
            ['wares_mold m','m.id = w.mid']
        ];

        $result = $this->alias('w')
            ->field('w.*,m.title as mtitle')
            ->join($join)
            ->where($map)
            ->limit($from, $size)
            ->order($order)
            ->select();
            
        return $result;
    }

    /**
     * [getWaresCountByCondition  根据搜索条件获取满足条数]
     * @author [南風]
     * @param $map
     * @return int|string
     */
    public function getWaresCountByCondition($map)
    {
        return $this->where($map)->count();
    }
}